package com.ruoyi.zhongkao.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zhongkao.domain.ZkGraduationSchool;
import com.ruoyi.zhongkao.service.IZkGraduationSchoolService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 毕业学校Controller
 * 
 * @author ruoyi
 * @date 2025-07-04
 */
@Api(tags = "中考-毕业学校管理")
@RestController
@RequestMapping("/zhongkao/graduationSchool")
public class ZkGraduationSchoolController extends BaseController
{
    @Autowired
    private IZkGraduationSchoolService zkGraduationSchoolService;


    /**
     * 查询毕业学校列表
     */
    //@PreAuthorize("@ss.hasPermi('zhongkao:school:list')")
    @GetMapping("/list")
        @ApiOperation("中考毕业学校管理 - 分页查询列表")
    public TableDataInfo list(ZkGraduationSchool zkGraduationSchool)
    {
        startPage();
        List<ZkGraduationSchool> list = zkGraduationSchoolService.selectZkGraduationSchoolList(zkGraduationSchool);
        return getDataTable(list);
    }

    @GetMapping("/all")
        @ApiOperation("中考毕业学校管理 - 查询所有数据")
    public AjaxResult getAll()
    {
        return success(zkGraduationSchoolService.selectZkGraduationSchoolAll());
    }
    /**
     * 导出毕业学校列表
     */
    //@PreAuthorize("@ss.hasPermi('zhongkao:school:export')")
    @Log(title = "毕业学校", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
        @ApiOperation("中考毕业学校管理 - 导出数据")
    public void export(HttpServletResponse response, ZkGraduationSchool zkGraduationSchool)
    {
        List<ZkGraduationSchool> list = zkGraduationSchoolService.selectZkGraduationSchoolList(zkGraduationSchool);
        ExcelUtil<ZkGraduationSchool> util = new ExcelUtil<ZkGraduationSchool>(ZkGraduationSchool.class);
        util.exportExcel(response, list, "毕业学校数据");
    }

    /**
     * 获取毕业学校详细信息
     */
    //@PreAuthorize("@ss.hasPermi('zhongkao:school:query')")
    @GetMapping(value = "/{id}")
        @ApiOperation("中考毕业学校管理 - 根据ID获取详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(zkGraduationSchoolService.selectZkGraduationSchoolById(id));
    }

    @GetMapping(value = "/selectByCode/{code}")
        @ApiOperation("中考毕业学校管理 - 根据ID获取详细信息")
    public AjaxResult getInfo(@PathVariable("code") String code)
    {
        return success(zkGraduationSchoolService.selectZkGraduationSchoolByCode(code));
    }
    /**
     * 新增毕业学校
     */
    //@PreAuthorize("@ss.hasPermi('zhongkao:school:add')")
    @Log(title = "毕业学校", businessType = BusinessType.INSERT)
    @PostMapping
        @ApiOperation("中考毕业学校管理 - 新增数据")
    public AjaxResult add(@RequestBody ZkGraduationSchool zkGraduationSchool)
    {
        return toAjax(zkGraduationSchoolService.insertZkGraduationSchool(zkGraduationSchool));
    }

    /**
     * 修改毕业学校
     */
    //@PreAuthorize("@ss.hasPermi('zhongkao:school:edit')")
    @Log(title = "毕业学校", businessType = BusinessType.UPDATE)
    @PutMapping
        @ApiOperation("中考毕业学校管理 - 修改数据")
    public AjaxResult edit(@RequestBody ZkGraduationSchool zkGraduationSchool)
    {
        return toAjax(zkGraduationSchoolService.updateZkGraduationSchool(zkGraduationSchool));
    }

    /**
     * 删除毕业学校
     */
    @PreAuthorize("@ss.hasPermi('zhongkao:school:remove')")
    @Log(title = "毕业学校", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
        @ApiOperation("中考毕业学校管理 - 删除数据")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(zkGraduationSchoolService.deleteZkGraduationSchoolByIds(ids));
    }
}
